package com.csht.service.Impl;

import java.util.List;
import java.util.Map;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import com.csht.mapper.CshtMessageReportMapper;
import com.csht.model.CshtMessageReport;
import com.csht.page.PagerModel;
import com.csht.service.CshtMessageReportService;
import com.csht.vo.my.CshtMessageReportVo;

/**
 * 留言举报记录service
 * @author chenhuiyan
 *
 */
@Service
public class CshtMessageReportServiceImpl implements CshtMessageReportService {
	
	@Autowired
	private CshtMessageReportMapper cshtMessageReportMapper;

	/**
	 * 根据用户id查询留言举报记录总数
	 */
	@Override
	public Integer getMessageReportNumberByUserId(Integer userId) throws Exception {
		Integer number = cshtMessageReportMapper.getMessageReportNumberByUserId(userId);
		return number;
	}

	/**
	 * 根据用户id查询留言举报记录
	 */
	@Override
	public PagerModel<CshtMessageReportVo> getMessageReportByUserId(Map<String, Integer> res) throws Exception {
		List<CshtMessageReportVo> cshtMessageReportVoList = cshtMessageReportMapper.getMessageReportByUserId(res);
		Integer totalSize = cshtMessageReportMapper.getMessageReportNumberByUserId(res.get("userId"));
		Integer offset = res.get("offset");
		Integer messagePageSize = res.get("messagePageSize");
		PagerModel<CshtMessageReportVo> pagerModelMessageReport = new PagerModel<CshtMessageReportVo>();
		pagerModelMessageReport.setDates(cshtMessageReportVoList);
		pagerModelMessageReport.setMessagePageSize(messagePageSize);
		pagerModelMessageReport.setOffset(offset);
		pagerModelMessageReport.setTotalSize(totalSize);
		return pagerModelMessageReport;
	}

	/**
	 * 根据留言举报id查询留言举报记录
	 */
	@Override
	public CshtMessageReportVo getMessageReportByMessageReportId(Integer messageReportId) throws Exception {
		CshtMessageReportVo cshtMessageReportVo = cshtMessageReportMapper.getMessageReportByMessageReportId(messageReportId);
		return cshtMessageReportVo;
	}

	/**
	 * 插入一条记录
	 */
	@Override
	public void insertMessageReport(CshtMessageReport cshtMessageReport) throws Exception {
		cshtMessageReportMapper.insertMessageReport(cshtMessageReport);
	}

}
